export const getStudyPage = (params: any) => {
	return new Promise<any>((resolve) => {
		const { date, device, name, age, gender } = params;
		const res = window.$.sendSync('API-PATIENT-QUERY-PAGE', {
			condition: { date: date ? [date[0], date[1]] : undefined, device: device ? device.map((e: any) => e) : undefined, name, age, gender: gender == '' ? undefined : gender },
			currentPage:0,
			pageCount:10
		});
		resolve(res);
	});
};

export const getStudyList = (condition:any) => {
	return new Promise((resolve) => {
		resolve(window.$.sendSync('API-PATIENT-QUERY', condition));
	});
};

export const getStudy = (id: string) => {
	return new Promise((resolve) => {
		resolve(window.$.sendSync('API-PATIENT-QUERY-UNIQUE', id));
	});
};

export const saveStudy = (data: any) => {
	return new Promise((resolve) => {
		window.$.sendSync('API-PATIENT-EDIT', data);
		resolve(null);
	});
};

export const getHistoryStudyByName = (name: string) => {
	return new Promise((resolve) => {
		resolve(window.$.sendSync('API-PATIENT-QUERY-HISTORY', name));
	});
};
